import type { ModalData } from '@/types'
import { useMountComponent } from '@/utils/component'
import { createVNode } from 'vue'
import Dialog from '@/components/base/ShowModal.vue'

export const showModal = (config: ModalData): Promise<string> => {
  const { instance, unmount } = useMountComponent(
    createVNode(Dialog, {
      unmount: () => {
        unmount()
      },
    }),
  )
  const vm = instance as InstanceType<typeof Dialog>
  return vm.asyncShowModal(config)
}
